<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blogs/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blogs/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blogs/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blogs/images/apple-touch-icon.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/blogs/images/favicon-32x32.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/blogs/images/favicon-16x16.png?v=5.1.3">


  <link rel="mask-icon" href="/blogs/images/logo.svg?v=5.1.3" color="#222">





  <meta name="keywords" content="JavaScript," />










<meta name="description" content="1.格式化时间输入一个标准时间 : 2022-06-01T13:43:26.044Z 输出：2022-05-01 21:43:26 12345678910111213141516171819&#x2F;** * 格式化时间 * @param date * @returns &amp;#123;string&amp;#125; *&#x2F;function formatDateTime (date) &amp;#123;    let ye">
<meta property="og:type" content="article">
<meta property="og:title" content="JS工具类">
<meta property="og:url" content="https://louchaoyy.gitee.io/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/index.html">
<meta property="og:site_name" content="Chao&#39;s blog">
<meta property="og:description" content="1.格式化时间输入一个标准时间 : 2022-06-01T13:43:26.044Z 输出：2022-05-01 21:43:26 12345678910111213141516171819&#x2F;** * 格式化时间 * @param date * @returns &amp;#123;string&amp;#125; *&#x2F;function formatDateTime (date) &amp;#123;    let ye">
<meta property="og:locale">
<meta property="og:image" content="https://louchaoyy.gitee.io/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/addtwonumber1.jpg">
<meta property="article:published_time" content="2022-06-01T13:40:06.000Z">
<meta property="article:modified_time" content="2022-07-06T15:06:35.505Z">
<meta property="article:author" content="Chaoyxy">
<meta property="article:tag" content="JavaScript">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://louchaoyy.gitee.io/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/addtwonumber1.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '',
    scheme: 'Gemini',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://louchaoyy.gitee.io/blogs/2022/06/01/JS工具类/"/>





  <title>JS工具类 | Chao's blog</title>
  








<meta name="generator" content="Hexo 5.4.0"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blogs/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Chao's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blogs/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blogs/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blogs/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://louchaoyy.gitee.io/blogs/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blogs/images/cat.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Chao's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">JS工具类</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2022-06-01T21:40:06+08:00">
                2022-06-01
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2022/06/01/JS工具类/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="1-格式化时间"><a href="#1-格式化时间" class="headerlink" title="1.格式化时间"></a>1.格式化时间</h2><p>输入一个标准时间 : <code>2022-06-01T13:43:26.044Z</code></p>
<p>输出：<code>2022-05-01 21:43:26</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 格式化时间</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">date</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;string&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">formatDateTime</span> (<span class="params">date</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">let</span> year = date.getFullYear();</span><br><span class="line">    <span class="keyword">let</span> month = date.getMonth();</span><br><span class="line">    month = month &lt; <span class="number">10</span> ? (<span class="string">&quot;0&quot;</span> + month) : month;</span><br><span class="line">    <span class="keyword">let</span> day = date.getDate();</span><br><span class="line">    day = day &lt; <span class="number">10</span> ? (<span class="string">&quot;0&quot;</span> + day) : day;</span><br><span class="line">    <span class="keyword">let</span> hours = date.getHours();</span><br><span class="line">    hours &lt; <span class="number">10</span> ? (<span class="string">&quot;0&quot;</span> + hours) : hours;</span><br><span class="line">    <span class="keyword">let</span> minute = date.getMinutes();</span><br><span class="line">    minute = minute &lt; <span class="number">10</span> ? (<span class="string">&quot;0&quot;</span> + minute) : minute;</span><br><span class="line">    <span class="keyword">let</span> second = date.getSeconds();</span><br><span class="line">    second = second &lt; <span class="number">10</span> ? (<span class="string">&quot;0&quot;</span> + second) : second;</span><br><span class="line">    <span class="keyword">return</span> year + <span class="string">&quot;-&quot;</span> + month + <span class="string">&quot;-&quot;</span> + day + <span class="string">&quot; &quot;</span> + hours + <span class="string">&quot;:&quot;</span> + minute + <span class="string">&quot;:&quot;</span> + second;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="2-查找数组里面指定元素的下标"><a href="#2-查找数组里面指定元素的下标" class="headerlink" title="2.查找数组里面指定元素的下标"></a>2.查找数组里面指定元素的下标</h2><p>输入：一个数组，数组 <code>[&quot;zhang&quot;,&quot;san&quot;,&quot;li&quot;,&quot;si&quot;,&quot;zhao&quot;,&quot;qian&quot;,&quot;sun&quot;],目标元素 &quot;zhao&quot;</code></p>
<p>输出：数组的下标：<code>4</code></p>
<span id="more"></span>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 查找数组里面指定元素的下标</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param </span>arr 数组</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param </span>str 目标元素</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;number&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">indexOfArray</span>(<span class="params">arr,str</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; arr.length; i++) &#123;</span><br><span class="line">        <span class="keyword">if</span> (arr[i]===str)&#123;</span><br><span class="line">            <span class="keyword">return</span> i;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> -<span class="number">1</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="3-删除某数组的指定元素"><a href="#3-删除某数组的指定元素" class="headerlink" title="3.删除某数组的指定元素"></a>3.删除某数组的指定元素</h2><p>输入：一个数组，数组 <code>[&quot;zhang&quot;,&quot;san&quot;,&quot;li&quot;,&quot;si&quot;,&quot;zhao&quot;,&quot;qian&quot;,&quot;sun&quot;],目标元素 &quot;zhao&quot;</code></p>
<p>输出：被删除的元素：<code>[&#39;zhao&#39;] </code></p>
<p>测试元数组：<code>[ &#39;zhang&#39;, &#39;san&#39;, &#39;li&#39;, &#39;si&#39;, &#39;qian&#39;, &#39;sun&#39; ]</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 删除数组里面的指定元素</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">arr</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">str</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">removeArray</span> (<span class="params">arr,str</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> index = indexOfArray(arr,str);</span><br><span class="line">    <span class="keyword">return</span> arr.splice(index,<span class="number">1</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="4-遍历对象的属性，并且返回数组的形式"><a href="#4-遍历对象的属性，并且返回数组的形式" class="headerlink" title="4.遍历对象的属性，并且返回数组的形式"></a>4.遍历对象的属性，并且返回数组的形式</h2><p>输入：一个对象：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> person = &#123;</span><br><span class="line">    <span class="attr">name</span>:<span class="string">&quot;louchao&quot;</span>,</span><br><span class="line">    <span class="attr">age</span>:<span class="number">20</span>,</span><br><span class="line">    <span class="attr">gender</span>:<span class="string">&quot;male&quot;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>输出：对象的属性组成的数组：<code>[ &#39;name&#39;, &#39;age&#39;, &#39;gender&#39; ]</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 遍历对象的属性，并且返回数组的形式</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">obj</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;[]&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getObjectKeyasArr</span> (<span class="params">obj</span>)</span>&#123;</span><br><span class="line">    <span class="comment">//属性个数</span></span><br><span class="line">    <span class="comment">// console.log(Object.keys(obj).length);</span></span><br><span class="line">    <span class="keyword">let</span> arr = [];</span><br><span class="line">    <span class="built_in">Object</span>.keys(obj).forEach(<span class="function">(<span class="params">key</span>)=&gt;</span>&#123;</span><br><span class="line">        arr.push(key);</span><br><span class="line">    &#125;)</span><br><span class="line">    <span class="keyword">return</span> arr;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="5-打印出间隔两个日期中的所有日期"><a href="#5-打印出间隔两个日期中的所有日期" class="headerlink" title="5.打印出间隔两个日期中的所有日期"></a>5.打印出间隔两个日期中的所有日期</h2><p>输入：起始日期和终止日期 <code>2022-12-25，2023-01-03 </code></p>
<p>输出：中间间隔的所有日期</p>
<p> 2022-12-25<br> 2022-12-26<br> 2022-12-27<br> 2022-12-28<br> 2022-12-29<br> 2022-12-30<br> 2022-12-31<br> 2023-01-01<br> 2023-01-02</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 打印出间隔两个日期中的所有日期</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">startDate</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">endDate</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getBetweenDate</span> (<span class="params">startDate,endDate</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> start = <span class="keyword">new</span> <span class="built_in">Date</span>(startDate);</span><br><span class="line">    <span class="keyword">let</span> end = <span class="keyword">new</span> <span class="built_in">Date</span>(endDate);</span><br><span class="line">    <span class="keyword">if</span> (start.getTime()&lt;=end.getTime())&#123;</span><br><span class="line">        <span class="keyword">while</span> (start.getTime()&lt;end.getTime())&#123;</span><br><span class="line">            <span class="keyword">let</span> year = start.getFullYear();</span><br><span class="line">            <span class="keyword">let</span> month = start.getMonth();</span><br><span class="line">            month = month&lt;<span class="number">9</span>?(<span class="string">&quot;0&quot;</span>+(<span class="built_in">parseInt</span>(month)+<span class="number">1</span>)):(<span class="built_in">parseInt</span>(month)+<span class="number">1</span>);</span><br><span class="line">            <span class="keyword">let</span> day = start.getDate();</span><br><span class="line">            day = day&lt;<span class="number">10</span>?(<span class="string">&quot;0&quot;</span>+<span class="built_in">parseInt</span>(day)):<span class="built_in">parseInt</span>(day);</span><br><span class="line">            <span class="keyword">let</span> everyDate = year+<span class="string">&quot;-&quot;</span>+month+<span class="string">&quot;-&quot;</span>+day;</span><br><span class="line">            <span class="built_in">console</span>.log(everyDate);</span><br><span class="line">            start.setDate(start.getDate()+<span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">&quot;输入时间有误&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="6-写出-0-9-之间的所有不同数字组成的三位数-并计算个数"><a href="#6-写出-0-9-之间的所有不同数字组成的三位数-并计算个数" class="headerlink" title="6.写出 0-9 之间的所有不同数字组成的三位数,并计算个数"></a>6.写出 0-9 之间的所有不同数字组成的三位数,并计算个数</h2><p>输入：无</p>
<p>输出：648</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 写出 0-9 之间的所有不同数字组成的三位数,并计算个数</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">setTripleNumber</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> count = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">1</span>; i &lt;= <span class="number">9</span>; i++) &#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">let</span> j = <span class="number">0</span>; j &lt;= <span class="number">9</span>; j++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (j===i) <span class="keyword">continue</span>;</span><br><span class="line">            <span class="keyword">for</span> (<span class="keyword">let</span> k = <span class="number">0</span>; k &lt;= <span class="number">9</span>; k++) &#123;</span><br><span class="line">                <span class="keyword">if</span> (k!==j&amp;&amp;k!==i)&#123;</span><br><span class="line">                    count++;</span><br><span class="line">                    <span class="built_in">console</span>.log(count+<span class="string">&quot;: &quot;</span>+i+j+k);</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">&quot;个数为：&quot;</span>+count);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="7-将两个一维数组合并成一个二维数组"><a href="#7-将两个一维数组合并成一个二维数组" class="headerlink" title="7.将两个一维数组合并成一个二维数组"></a>7.将两个一维数组合并成一个二维数组</h2><p>输入：arr 1: [“zhang”,”san”,”li”,”si”,”zhao”,”qian”] , arr 2: [1,32,3,45,67]</p>
<p>输出：</p>
<p>[<br>  [ ‘zhang’, 1 ],<br>  [ ‘san’, 32 ],<br>  [ ‘li’, 3 ],<br>  [ ‘si’, 45 ],<br>  [ ‘zhao’, 67 ]<br>]</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 合并两个数组</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">arr1</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">arr2</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;[]&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">mergeArray</span>(<span class="params">arr1,arr2</span>)=&gt;</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> arrLength = arr1.length&lt;arr2.length?arr1.length:arr2.length;</span><br><span class="line">    <span class="keyword">let</span> newArray = [];</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt;arrLength ; i++) &#123;</span><br><span class="line">        newArray.push([arr1[i],arr2[i]]);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> newArray;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>测试：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> array1 = [<span class="string">&quot;zhang&quot;</span>,<span class="string">&quot;san&quot;</span>,<span class="string">&quot;li&quot;</span>,<span class="string">&quot;si&quot;</span>,<span class="string">&quot;zhao&quot;</span>,<span class="string">&quot;qian&quot;</span>];</span><br><span class="line"><span class="keyword">let</span> array2 = [<span class="number">1</span>,<span class="number">32</span>,<span class="number">3</span>,<span class="number">45</span>,<span class="number">67</span>];</span><br><span class="line"><span class="keyword">const</span> res = utils.mergeArray(array1,array2);</span><br><span class="line"><span class="built_in">console</span>.log(res);</span><br><span class="line"></span><br><span class="line"><span class="comment">//结果：</span></span><br><span class="line">[</span><br><span class="line">  [ <span class="string">&#x27;zhang&#x27;</span>, <span class="number">1</span> ],</span><br><span class="line">  [ <span class="string">&#x27;san&#x27;</span>, <span class="number">32</span> ],</span><br><span class="line">  [ <span class="string">&#x27;li&#x27;</span>, <span class="number">3</span> ],</span><br><span class="line">  [ <span class="string">&#x27;si&#x27;</span>, <span class="number">45</span> ],</span><br><span class="line">  [ <span class="string">&#x27;zhao&#x27;</span>, <span class="number">67</span> ]</span><br><span class="line">]</span><br></pre></td></tr></table></figure>

<p><strong>说明</strong>：<strong>两个一维数组，以数组长度短的为准，超出的部分会截断，被丢失掉，如上例中 arr 1中的”qian“元素丢失掉</strong></p>
<h2 id="8-将一个数组map的两个元素合并成一个对象，第一个元素作为key-第二个元素作为value"><a href="#8-将一个数组map的两个元素合并成一个对象，第一个元素作为key-第二个元素作为value" class="headerlink" title="8.将一个数组map的两个元素合并成一个对象，第一个元素作为key,第二个元素作为value"></a>8.将一个数组map的两个元素合并成一个对象，第一个元素作为key,第二个元素作为value</h2><p>输入：[{<br>        alarmName:”报警停机”,<br>        alarmType: 0,<br>    },<br>    {<br>        alarmName:”闭锁”,<br>        alarmType: 1,<br>    },<br>    {<br>        alarmName:”警告”,<br>        alarmType: 2,<br>    },<br>    {<br>        alarmName:”跳闸”,<br>        alarmType: 3,<br>    },<br>    {<br>        alarmName:”跳闸停机”,<br>        alarmType: 4,<br>    }<br>]</p>
<p>输出：<code>&#123; &#39;报警停机&#39;: 0, &#39;闭锁&#39;: 1, &#39;警告&#39;: 2, &#39;跳闸&#39;: 3, &#39;跳闸停机&#39;: 4 &#125;</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 参数：数组map</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">array</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="built_in">exports</span>.mergeArrayObj = <span class="function">(<span class="params">array</span>)=&gt;</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> obj = &#123;&#125;;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> item <span class="keyword">in</span> array) &#123;</span><br><span class="line">        obj[array[item].alarmName] = array[item].alarmType</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> obj;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>测试：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> data = [</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">alarmName</span>:<span class="string">&quot;报警停机&quot;</span>,</span><br><span class="line">        <span class="attr">alarmType</span>:<span class="number">0</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">alarmName</span>:<span class="string">&quot;闭锁&quot;</span>,</span><br><span class="line">        <span class="attr">alarmType</span>:<span class="number">1</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">alarmName</span>:<span class="string">&quot;警告&quot;</span>,</span><br><span class="line">        <span class="attr">alarmType</span>:<span class="number">2</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">alarmName</span>:<span class="string">&quot;跳闸&quot;</span>,</span><br><span class="line">        <span class="attr">alarmType</span>:<span class="number">3</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">alarmName</span>:<span class="string">&quot;跳闸停机&quot;</span>,</span><br><span class="line">        <span class="attr">alarmType</span>:<span class="number">4</span>,</span><br><span class="line">    &#125;</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> result = utils.mergeArrayObj(data);</span><br><span class="line"><span class="built_in">console</span>.log(result)</span><br><span class="line"></span><br><span class="line"><span class="comment">//结果：&#123; &#x27;报警停机&#x27;: 0, &#x27;闭锁&#x27;: 1, &#x27;警告&#x27;: 2, &#x27;跳闸&#x27;: 3, &#x27;跳闸停机&#x27;: 4 &#125;</span></span><br></pre></td></tr></table></figure>

<h2 id="9-将一个对象转化为一个对象数组（listMap）"><a href="#9-将一个对象转化为一个对象数组（listMap）" class="headerlink" title="9.将一个对象转化为一个对象数组（listMap）"></a>9.将一个对象转化为一个对象数组（listMap）</h2><p>输入：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="string">&quot;zhangsan&quot;</span>:<span class="string">&quot;eatting&quot;</span>,</span><br><span class="line">     <span class="string">&quot;lisi&quot;</span>:<span class="string">&quot;playing&quot;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>输出：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">key</span>:<span class="string">&quot;zhangsan&quot;</span>,</span><br><span class="line">        <span class="attr">value</span>:<span class="string">&quot;eatting&quot;</span></span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="attr">key</span>:<span class="string">&quot;lisi&quot;</span>,</span><br><span class="line">        <span class="attr">value</span>:<span class="string">&quot;playing&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line">]</span><br></pre></td></tr></table></figure>

<p>代码</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">objToArrobj</span>(<span class="params">obj</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> listData = [];</span><br><span class="line">    <span class="built_in">Object</span>.keys(obj).forEach(<span class="function"><span class="params">key</span>=&gt;</span>&#123;</span><br><span class="line">        <span class="keyword">let</span> newObj = &#123;&#125;;</span><br><span class="line">        newObj.key = key;</span><br><span class="line">        newObj.value = obj[key];</span><br><span class="line">        listData.push(newObj);</span><br><span class="line">    &#125;)</span><br><span class="line">    <span class="keyword">return</span> listData;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>测试：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//输入：</span></span><br><span class="line"><span class="keyword">let</span> objdata = &#123;</span><br><span class="line">    <span class="string">&quot;genPowerNormal&quot;</span>:<span class="string">&quot;0&quot;</span>,</span><br><span class="line">    <span class="string">&quot;sysManualMode&quot;</span>:<span class="string">&quot;0&quot;</span>,</span><br><span class="line">    <span class="string">&quot;reservedSwitch&quot;</span>:<span class="string">&quot;1&quot;</span>,</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//测试代码</span></span><br><span class="line"><span class="keyword">const</span> rr = utils.objToArrobj(objdata);</span><br><span class="line"><span class="built_in">console</span>.log(rr);</span><br><span class="line"></span><br><span class="line"><span class="comment">//结果：</span></span><br><span class="line">[</span><br><span class="line">  &#123; <span class="attr">key</span>: <span class="string">&#x27;genPowerNormal&#x27;</span>, <span class="attr">value</span>: <span class="string">&#x27;0&#x27;</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">key</span>: <span class="string">&#x27;sysManualMode&#x27;</span>, <span class="attr">value</span>: <span class="string">&#x27;0&#x27;</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">key</span>: <span class="string">&#x27;reservedSwitch&#x27;</span>, <span class="attr">value</span>: <span class="string">&#x27;1&#x27;</span> &#125;</span><br><span class="line">]</span><br></pre></td></tr></table></figure>

<h2 id="10-将一个字符串反转，逆序输出"><a href="#10-将一个字符串反转，逆序输出" class="headerlink" title="10.将一个字符串反转，逆序输出"></a>10.将一个字符串反转，逆序输出</h2><p>输入：Hello World</p>
<p>输出：dlroW olleH</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 反转字符串</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">str</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;string&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">reverseString</span>(<span class="params">str</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">return</span> [...str].reverse().join(<span class="string">&quot;&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="11-统计一个字符串里面重复次数最多的字符"><a href="#11-统计一个字符串里面重复次数最多的字符" class="headerlink" title="11.统计一个字符串里面重复次数最多的字符"></a>11.统计一个字符串里面重复次数最多的字符</h2><p>输入：<code>aabbbgdggggssjdjsgdjs</code></p>
<p>输出：g,6次</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 统计一个字符串里面重复次数最多的字符</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">str</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;string&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">countRepeatStr</span>(<span class="params">str</span>)</span>&#123;</span><br><span class="line">    <span class="comment">//对字符串进行去重</span></span><br><span class="line">    <span class="keyword">let</span> set = <span class="keyword">new</span> <span class="built_in">Set</span>(str);</span><br><span class="line">    <span class="comment">//转化为数组</span></span><br><span class="line">    <span class="keyword">let</span> strArr = [...set];</span><br><span class="line">    <span class="keyword">let</span> tmpObj = &#123;&#125;;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//为每个字符建立一个空数组</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt;strArr.length ; i++) &#123;</span><br><span class="line">        tmpObj[i] = [];</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//遍历,如果字符串中的某个值和去重后的数组里面的值相等，说明重复，则往空数组里面加一个值</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> j = <span class="number">0</span>; j &lt; strArr.length; j++) &#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">let</span> k = <span class="number">0</span>; k &lt; str.length ; k++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (strArr[j]===str[k])&#123;</span><br><span class="line">                tmpObj[j].push(str[k])</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//排序</span></span><br><span class="line">    <span class="comment">//使用对象数组的value作为索引</span></span><br><span class="line">    <span class="keyword">let</span> val = <span class="built_in">Object</span>.values(tmpObj);</span><br><span class="line">    val.sort(<span class="function">(<span class="params">a,b</span>)=&gt;</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> b.length - a.length;</span><br><span class="line">    &#125;)</span><br><span class="line">    <span class="comment">//使用map把结果遍历出来</span></span><br><span class="line">    <span class="comment">// return val.map((item)=&gt;&#123;return `$&#123;item&#125;的重复次数为：$&#123;item.length&#125;`&#125;);</span></span><br><span class="line">    <span class="comment">//返回重复次数最多的字母</span></span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;重复次数最多的是字母&quot;</span>+val[<span class="number">0</span>][<span class="number">0</span>]+<span class="string">&quot;,重复次数为：&quot;</span>+val[<span class="number">0</span>].length+<span class="string">&quot;次&quot;</span>;</span><br><span class="line">    <span class="keyword">return</span> val[<span class="number">0</span>][<span class="number">0</span>]+<span class="string">&quot;,&quot;</span>+val[<span class="number">0</span>].length+<span class="string">&quot;次&quot;</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="12-把一个十进制数转化成2进制，并统计”1“的个数"><a href="#12-把一个十进制数转化成2进制，并统计”1“的个数" class="headerlink" title="12.把一个十进制数转化成2进制，并统计”1“的个数"></a>12.把一个十进制数转化成2进制，并统计”1“的个数</h2><p>输入：126</p>
<p>输出：6</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 统计十进制转化成2进制数包含的”1“的个数</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">num</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;number&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">countOneBinary</span>(<span class="params">num</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> count = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">let</span> binaryNum = num.toString(<span class="number">2</span>);</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; [...binaryNum].length; i++) &#123;</span><br><span class="line">        <span class="keyword">if</span> ([...binaryNum][i]===<span class="string">&#x27;1&#x27;</span>)&#123;</span><br><span class="line">            count++;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> count;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="13-给定一个整数数组-nums-和一个整数目标值-target，请你在该数组中找出-和为目标值-target-的那-两个-整数，并返回它们的数组下标。"><a href="#13-给定一个整数数组-nums-和一个整数目标值-target，请你在该数组中找出-和为目标值-target-的那-两个-整数，并返回它们的数组下标。" class="headerlink" title="13.给定一个整数数组 nums 和一个整数目标值 target，请你在该数组中找出 和为目标值 target 的那 两个 整数，并返回它们的数组下标。"></a>13.给定一个整数数组 <code>nums</code> 和一个整数目标值 <code>target</code>，请你在该数组中找出 <strong>和为目标值</strong> <em><code>target</code></em> 的那 <strong>两个</strong> 整数，并返回它们的数组下标。</h2><p>你可以假设每种输入只会对应一个答案。但是，数组中同一个元素在答案里不能重复出现。</p>
<p>你可以按任意顺序返回答案。</p>
<p><strong>示例 1：</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">输入：nums = [2,7,11,15], target = 9</span><br><span class="line">输出：[0,1]</span><br><span class="line">解释：因为 nums[0] + nums[1] == 9 ，返回 [0, 1] 。</span><br></pre></td></tr></table></figure>

<p><strong>示例 2：</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">输入：nums = [3,2,4], target = 6</span><br><span class="line">输出：[1,2]</span><br></pre></td></tr></table></figure>

<p><strong>示例 3：</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">输入：nums = [3,3], target = 6</span><br><span class="line">输出：[0,1]</span><br></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> twoSum = <span class="function"><span class="keyword">function</span>(<span class="params">nums, target</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">let</span> i = <span class="number">0</span> ; i &lt; nums.length-<span class="number">1</span>; i++)&#123;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">let</span> j = i+<span class="number">1</span>; j &lt; nums.length;j++)&#123;</span><br><span class="line">            <span class="keyword">if</span>(nums[i]+nums[j]===target)&#123;</span><br><span class="line">                <span class="keyword">return</span> [i,j]</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="14-给你两个-非空-的链表，表示两个非负的整数。它们每位数字都是按照-逆序-的方式存储的，并且每个节点只能存储-一位数字。"><a href="#14-给你两个-非空-的链表，表示两个非负的整数。它们每位数字都是按照-逆序-的方式存储的，并且每个节点只能存储-一位数字。" class="headerlink" title="14.给你两个 非空 的链表，表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的，并且每个节点只能存储 一位数字。"></a>14.给你两个 <strong>非空</strong> 的链表，表示两个非负的整数。它们每位数字都是按照 <strong>逆序</strong> 的方式存储的，并且每个节点只能存储 <strong>一位</strong>数字。</h2><p>请你将两个数相加，并以相同形式返回一个表示和的链表。</p>
<p>你可以假设除了数字 0 之外，这两个数都不会以 0 开头。</p>
<p><strong>示例 1：</strong></p>
<img src="/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/addtwonumber1.jpg" class title="链表反转相加">

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">输入：l1 = [2,4,3], l2 = [5,6,4]</span><br><span class="line">输出：[7,0,8]</span><br><span class="line">解释：342 + 465 = 807.</span><br></pre></td></tr></table></figure>

<p><strong>示例 2：</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">输入：l1 = [0], l2 = [0]</span><br><span class="line">输出：[0]</span><br></pre></td></tr></table></figure>

<p><strong>示例 3：</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">输入：l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]</span><br><span class="line">输出：[8,9,9,9,0,0,0,1]</span><br></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 链表数组相加反转</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">l1</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param <span class="variable">l2</span></span></span></span><br><span class="line"><span class="comment"> * <span class="doctag">@returns <span class="type">&#123;[]&#125;</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="built_in">exports</span>.addTwoNumbers = <span class="function">(<span class="params">l1, l2</span>)=&gt;</span> &#123;</span><br><span class="line">    <span class="comment">//将数组反转</span></span><br><span class="line">    <span class="keyword">let</span> arr1 = l1.reverse();</span><br><span class="line">    <span class="keyword">let</span> arr2 = l2.reverse();</span><br><span class="line">    <span class="comment">//不够位数补0</span></span><br><span class="line">    <span class="keyword">if</span> (l1.length&lt;l2.length)&#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">let</span> i = l1.length; i &lt; l2.length; i++) &#123;</span><br><span class="line">            l1.push(<span class="number">0</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">let</span> i = l2.length; i &lt; l1.length; i++) &#123;</span><br><span class="line">            l2.push(<span class="number">0</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">let</span> length = l1.length&gt;l2.length?l1.length:l2.length;</span><br><span class="line">    <span class="keyword">let</span> res = [];</span><br><span class="line">    <span class="comment">//进行相加</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; length; i++) &#123;</span><br><span class="line">       <span class="keyword">if</span> (i&lt;length-<span class="number">1</span>)&#123;</span><br><span class="line">           <span class="keyword">if</span> (arr1[i]+arr2[i]&gt;=<span class="number">10</span>)&#123;</span><br><span class="line">               res.push((arr1[i]+arr2[i])%<span class="number">10</span>);</span><br><span class="line">               arr2[i+<span class="number">1</span>] = arr2[i+<span class="number">1</span>]+<span class="number">1</span>;</span><br><span class="line">           &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">               res.push(arr1[i]+arr2[i]);</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">           <span class="keyword">if</span> (arr1[i]+arr2[i]&gt;=<span class="number">10</span>)&#123;</span><br><span class="line">               res.push((arr1[i]+arr2[i])%<span class="number">10</span>);</span><br><span class="line">               res.push(<span class="number">1</span>);</span><br><span class="line">           &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">               res.push(arr1[i]+arr2[i]);</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> res;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="http://chaoyxy.cn/data/User/admin/home/desktop/images/alipay.jpg" alt=" 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="http://chaoyxy.cn/data/User/admin/home/desktop/images/wechatpay.jpg" alt=" 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blogs/tags/JavaScript/" rel="tag"># JavaScript</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blogs/2022/05/21/TypeScript%E7%BC%96%E8%AF%91%E6%89%93%E5%8C%85%E5%A4%84%E7%90%86/" rel="next" title="TypeScript编译打包处理">
                <i class="fa fa-chevron-left"></i> TypeScript编译打包处理
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blogs/2022/06/02/JS%E6%B5%85%E6%8B%B7%E8%B4%9D%E5%92%8C%E6%B7%B1%E6%8B%B7%E8%B4%9D%E7%9A%84%E5%AE%9E%E7%8E%B0/" rel="prev" title="JS浅拷贝和深拷贝的实现">
                JS浅拷贝和深拷贝的实现 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a target="_blank" rel="noopener" href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/blogs/images/cat.jpg"
                alt="" />
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blogs/archives">
              
                  <span class="site-state-item-count">43</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/blogs/tags/index.html">
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://gitee.com/louchaoyy" target="_blank" title="Gitee">
                      
                        <i class="fa fa-fw fa-gitee"></i>Gitee</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="louchao@louchaoyy.cn" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%97%B6%E9%97%B4"><span class="nav-number">1.</span> <span class="nav-text">1.格式化时间</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%9F%A5%E6%89%BE%E6%95%B0%E7%BB%84%E9%87%8C%E9%9D%A2%E6%8C%87%E5%AE%9A%E5%85%83%E7%B4%A0%E7%9A%84%E4%B8%8B%E6%A0%87"><span class="nav-number">2.</span> <span class="nav-text">2.查找数组里面指定元素的下标</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%88%A0%E9%99%A4%E6%9F%90%E6%95%B0%E7%BB%84%E7%9A%84%E6%8C%87%E5%AE%9A%E5%85%83%E7%B4%A0"><span class="nav-number">3.</span> <span class="nav-text">3.删除某数组的指定元素</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E9%81%8D%E5%8E%86%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%B9%B6%E4%B8%94%E8%BF%94%E5%9B%9E%E6%95%B0%E7%BB%84%E7%9A%84%E5%BD%A2%E5%BC%8F"><span class="nav-number">4.</span> <span class="nav-text">4.遍历对象的属性，并且返回数组的形式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E6%89%93%E5%8D%B0%E5%87%BA%E9%97%B4%E9%9A%94%E4%B8%A4%E4%B8%AA%E6%97%A5%E6%9C%9F%E4%B8%AD%E7%9A%84%E6%89%80%E6%9C%89%E6%97%A5%E6%9C%9F"><span class="nav-number">5.</span> <span class="nav-text">5.打印出间隔两个日期中的所有日期</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E5%86%99%E5%87%BA-0-9-%E4%B9%8B%E9%97%B4%E7%9A%84%E6%89%80%E6%9C%89%E4%B8%8D%E5%90%8C%E6%95%B0%E5%AD%97%E7%BB%84%E6%88%90%E7%9A%84%E4%B8%89%E4%BD%8D%E6%95%B0-%E5%B9%B6%E8%AE%A1%E7%AE%97%E4%B8%AA%E6%95%B0"><span class="nav-number">6.</span> <span class="nav-text">6.写出 0-9 之间的所有不同数字组成的三位数,并计算个数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-%E5%B0%86%E4%B8%A4%E4%B8%AA%E4%B8%80%E7%BB%B4%E6%95%B0%E7%BB%84%E5%90%88%E5%B9%B6%E6%88%90%E4%B8%80%E4%B8%AA%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84"><span class="nav-number">7.</span> <span class="nav-text">7.将两个一维数组合并成一个二维数组</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8-%E5%B0%86%E4%B8%80%E4%B8%AA%E6%95%B0%E7%BB%84map%E7%9A%84%E4%B8%A4%E4%B8%AA%E5%85%83%E7%B4%A0%E5%90%88%E5%B9%B6%E6%88%90%E4%B8%80%E4%B8%AA%E5%AF%B9%E8%B1%A1%EF%BC%8C%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%85%83%E7%B4%A0%E4%BD%9C%E4%B8%BAkey-%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%85%83%E7%B4%A0%E4%BD%9C%E4%B8%BAvalue"><span class="nav-number">8.</span> <span class="nav-text">8.将一个数组map的两个元素合并成一个对象，第一个元素作为key,第二个元素作为value</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#9-%E5%B0%86%E4%B8%80%E4%B8%AA%E5%AF%B9%E8%B1%A1%E8%BD%AC%E5%8C%96%E4%B8%BA%E4%B8%80%E4%B8%AA%E5%AF%B9%E8%B1%A1%E6%95%B0%E7%BB%84%EF%BC%88listMap%EF%BC%89"><span class="nav-number">9.</span> <span class="nav-text">9.将一个对象转化为一个对象数组（listMap）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#10-%E5%B0%86%E4%B8%80%E4%B8%AA%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%8F%8D%E8%BD%AC%EF%BC%8C%E9%80%86%E5%BA%8F%E8%BE%93%E5%87%BA"><span class="nav-number">10.</span> <span class="nav-text">10.将一个字符串反转，逆序输出</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#11-%E7%BB%9F%E8%AE%A1%E4%B8%80%E4%B8%AA%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%87%8C%E9%9D%A2%E9%87%8D%E5%A4%8D%E6%AC%A1%E6%95%B0%E6%9C%80%E5%A4%9A%E7%9A%84%E5%AD%97%E7%AC%A6"><span class="nav-number">11.</span> <span class="nav-text">11.统计一个字符串里面重复次数最多的字符</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#12-%E6%8A%8A%E4%B8%80%E4%B8%AA%E5%8D%81%E8%BF%9B%E5%88%B6%E6%95%B0%E8%BD%AC%E5%8C%96%E6%88%902%E8%BF%9B%E5%88%B6%EF%BC%8C%E5%B9%B6%E7%BB%9F%E8%AE%A1%E2%80%9D1%E2%80%9C%E7%9A%84%E4%B8%AA%E6%95%B0"><span class="nav-number">12.</span> <span class="nav-text">12.把一个十进制数转化成2进制，并统计”1“的个数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-%E7%BB%99%E5%AE%9A%E4%B8%80%E4%B8%AA%E6%95%B4%E6%95%B0%E6%95%B0%E7%BB%84-nums-%E5%92%8C%E4%B8%80%E4%B8%AA%E6%95%B4%E6%95%B0%E7%9B%AE%E6%A0%87%E5%80%BC-target%EF%BC%8C%E8%AF%B7%E4%BD%A0%E5%9C%A8%E8%AF%A5%E6%95%B0%E7%BB%84%E4%B8%AD%E6%89%BE%E5%87%BA-%E5%92%8C%E4%B8%BA%E7%9B%AE%E6%A0%87%E5%80%BC-target-%E7%9A%84%E9%82%A3-%E4%B8%A4%E4%B8%AA-%E6%95%B4%E6%95%B0%EF%BC%8C%E5%B9%B6%E8%BF%94%E5%9B%9E%E5%AE%83%E4%BB%AC%E7%9A%84%E6%95%B0%E7%BB%84%E4%B8%8B%E6%A0%87%E3%80%82"><span class="nav-number">13.</span> <span class="nav-text">13.给定一个整数数组 nums 和一个整数目标值 target，请你在该数组中找出 和为目标值 target 的那 两个 整数，并返回它们的数组下标。</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#14-%E7%BB%99%E4%BD%A0%E4%B8%A4%E4%B8%AA-%E9%9D%9E%E7%A9%BA-%E7%9A%84%E9%93%BE%E8%A1%A8%EF%BC%8C%E8%A1%A8%E7%A4%BA%E4%B8%A4%E4%B8%AA%E9%9D%9E%E8%B4%9F%E7%9A%84%E6%95%B4%E6%95%B0%E3%80%82%E5%AE%83%E4%BB%AC%E6%AF%8F%E4%BD%8D%E6%95%B0%E5%AD%97%E9%83%BD%E6%98%AF%E6%8C%89%E7%85%A7-%E9%80%86%E5%BA%8F-%E7%9A%84%E6%96%B9%E5%BC%8F%E5%AD%98%E5%82%A8%E7%9A%84%EF%BC%8C%E5%B9%B6%E4%B8%94%E6%AF%8F%E4%B8%AA%E8%8A%82%E7%82%B9%E5%8F%AA%E8%83%BD%E5%AD%98%E5%82%A8-%E4%B8%80%E4%BD%8D%E6%95%B0%E5%AD%97%E3%80%82"><span class="nav-number">14.</span> <span class="nav-text">14.给你两个 非空 的链表，表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的，并且每个节点只能存储 一位数字。</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Chaoyxy</span>

  
</div>

<span id="busuanzi_container_site_pv">
    本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<!--

  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.3</div>
-->




        







        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/blogs/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blogs/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blogs/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blogs/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blogs/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blogs/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/blogs/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/blogs/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/blogs/js/src/motion.js?v=5.1.3"></script>



  
  


  <script type="text/javascript" src="/blogs/js/src/affix.js?v=5.1.3"></script>

  <script type="text/javascript" src="/blogs/js/src/schemes/pisces.js?v=5.1.3"></script>



  
  <script type="text/javascript" src="/blogs/js/src/scrollspy.js?v=5.1.3"></script>
<script type="text/javascript" src="/blogs/js/src/post-details.js?v=5.1.3"></script>



  


  <script type="text/javascript" src="/blogs/js/src/bootstrap.js?v=5.1.3"></script>



  


  

    
      <script id="dsq-count-scr" src="https://Chaoyxy.disqus.com/count.js" async></script>
    

    
      <script type="text/javascript">
        var disqus_config = function () {
          this.page.url = 'https://louchaoyy.gitee.io/blogs/2022/06/01/JS%E5%B7%A5%E5%85%B7%E7%B1%BB/';
          this.page.identifier = '2022/06/01/JS工具类/';
          this.page.title = 'JS工具类';
        };
        var d = document, s = d.createElement('script');
        s.src = 'https://Chaoyxy.disqus.com/embed.js';
        s.setAttribute('data-timestamp', '' + +new Date());
        (d.head || d.body).appendChild(s);
      </script>
    

  




	





  














  





  

  

  

  
  

  

  

  

</body>
</html>
